package com.second.app.thread.wait.p_c;

import com.second.app.thread.p_c_test.ValueObject;

/**
 * @Author GYZ
 * <pre>
 *
 * </pre>
 */
public class CustomerDemo {

    private final String lock;

    public CustomerDemo(String lock) {
        this.lock = lock;
    }

    public void getValue() {
        try {
            synchronized (lock) {
                if (ValueObject.getValue().equals("")) {
                    lock.wait();
                }
                System.out.println(Thread.currentThread().getName()+"，get的值是 " + ValueObject.getValue());
                ValueObject.setValue("");
                lock.notify();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}

